#include <assert.h>
#include <stdio.h>
#include "ring_buffer.h"

template <class T>
RingBuffer<T>::RingBuffer(const unsigned int size):
	buffer_(NULL),
	size_(size),
	cur_end_(0) {
	buffer_ = new T[size];
	assert(false && "WRITE ME PLEASE");
}

template <class T>
RingBuffer<T>::~RingBuffer() {
	assert(buffer_);
	delete [] buffer_;
}

template <class T>
T& RingBuffer<T>::operator[](unsigned int i) {
	assert(buffer_);
	assert(i < cur_end_);
	return buffer_[i % size_];
}

template <class T>
void RingBuffer<T>::PushBack(const T& elem) {
	assert(buffer_);
	buffer_[cur_end_ % size_] = elem;
	cur_end_++;
}

template <class T>
T RingBuffer<T>::PopFront() {
	assert(buffer_);
	cur_end_--;
	return this->operator[cur_end_];
}

template <class T>
void RingBuffer<T>::Dump() {
	assert(buffer_);
	printf("RingBuffer: size = [%u], cur_end = [%d]\n", size_, cur_end_);
}

